﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Model;
using Ext.Net;
public partial class Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnLogin_Click(object sender, DirectEventArgs e)
    {
        using (var m=new ACEntities())
        {
            string username = txtUsername.Text;
            string passwd = txtPassword.Text;
            int result = (from c in m.Users
                          where c.username == username && c.passwd == passwd
                          select c).Count();
            if (result > 0 )
            {
                var q = (from c in m.Users
                         where c.username == username && c.passwd == passwd
                         select c).FirstOrDefault();
                Cookies.addCookies("username",q.username,0);
                Cookies.addCookies("uid",q.ID.ToString(),0);
                Response.Redirect("~/Default.aspx");
            }
            else
            {
                txtPassword.Text = "";
                X.Msg.Notify("提醒","用户名或密码错误！").Show();
            }
        }
    }
}